module FormBuilderAutocompleteExtension

  def autocomplete_field id, method, options = {} 
    if !options[:autocompleteId] 
      options[:autocompleteId] = id
    end    
    newOptions = options.clone
    newOptions[:validate] = false    
    jstag = @template.javascript_tag "initializeAutocomplete('#{options[:autocompleteId]}', '#{method}');" 
    "#{text_field id, options} #{hidden_field id, newOptions}".html_safe + jstag
  end

end